Public Class Session
    Protected mlID As Long
    Protected mlDatabaseID As Long
    Protected msCreateDate As String = Now

    Protected mbObjectExists As Boolean = False

    Public Const NODATA As Long = DBBase.NODATA

    Public Sub New()

    End Sub

    Public Sub New(ByVal lID As Long)
        mlID = lID

        mbObjectExists = True
    End Sub

    Public Property ID() As Long
        Get
            Return mlID
        End Get
        Set(ByVal value As Long)
            mlID = value
        End Set
    End Property

    Public Property DatabaseID() As Long
        Get
            Return mlDatabaseID
        End Get
        Set(ByVal value As Long)
            mlDatabaseID = value
        End Set
    End Property

    Public Property CreateDate() As String
        Get
            Return msCreateDate
        End Get
        Set(ByVal value As String)
            msCreateDate = value
        End Set
    End Property

#Region "database"
    Public Sub Load()
        Dim oObject As New DBSession

        oObject.Load(Me)
    End Sub

    Public Sub Save()
        Dim oObject As New DBSession

        If mbObjectExists = False Then
            Me.CreateDate = Now
            oObject.Add(Me)
            mbObjectExists = True
        End If
    End Sub

    Public Sub Delete()
        Dim oObject As New DBSession

        oObject.Delete(Me)
        mbObjectExists = False
    End Sub
#End Region
End Class
